package com.exam.mapper;

import com.exam.entity.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RegisterMapper {

    @Insert("insert into user_info(id,username,password,status,phone,email) " +
            "values(#{id},#{username},#{password} , #{status }, #{phone}, #{email})")
    public int addUser(String id, String username, String password,int status,
                       String phone,String email);

    @Select("select id, username from user_info where username = #{username}")
    List<User> findByName(String username);

    @Update("update user_info set password = #{password} where email = #{email}")
    public int updateByEmail(String email,String password);

    @Update("update user_info set password = #{password} where phone = #{phone}")
    public int updateByPhone(String phone,String password);

    @Select("select id, username from user_info where phone = #{phone}")
    List<User> findByPhone(String phone);

    @Select("select id, username from user_info where email = #{email}")
    List<User> findByEmail(String email);
}
